<?php


namespace app\admin\controller;

use app\AdminBaseController;
use app\admin\model\Admin as AdminModel;
use think\facade\Request;
use think\facade\View;

class Admin extends AdminBaseController
{
    //首页admi数据列表
    function index(){
        //判断是否是ajax请求
        if (Request::isAjax()){
            //返回Admin列表数据
            $admins = AdminModel::order('id','asc')->paginate(Request::get('limit'));
            return $this->jsonApi('用户数据','0',$admins->items(),['count'=>$admins->total(),'limit'=>Request::get('limit')]);
        }
        //打开页面
        return View::fetch();
    }

    //列表数据是否启用
    public function status(){
        $data = Request::post();
        $admin = AdminModel::update(['status' => $data['status'], 'id' => $data['id']]);
        if (empty($admin)){
            $this->jsonApi("设置失败！",0);
        }
        $this->jsonApi("设置成功！");
    }

    function add(){
        return "管理员添加";
    }

    function edit(){
        return "管理员编辑";
    }

    function delete(){
        return "管理员删除";
    }


}